<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Test if the DOM implementation implements a specific feature</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="domimplementation.createdocumenttype.html">DOMImplementation::createDocumentType</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="class.domnamednodemap.html">DOMNamedNodeMap</a></div>
 <div class="up"><a href="class.domimplementation.html">DOMImplementation</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="domimplementation.hasfeature" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">DOMImplementation::hasFeature</h1>
  <p class="verinfo">(PHP 5)</p><p class="refpurpose"><span class="refname">DOMImplementation::hasFeature</span> &mdash; <span class="dc-title">
   Test if the DOM implementation implements a specific feature
  </span></p>

 </div>
 <div class="refsect1 description" id="refsect1-domimplementation.hasfeature-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">bool</span> <span class="methodname"><strong>DOMImplementation::hasFeature</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$feature</code></span>
   , <span class="methodparam"><span class="type">string</span> <code class="parameter">$version</code></span>
   )</div>

  <p class="para rdfs-comment">
   Test if the DOM implementation implements a specific 
   <em><code class="parameter">feature</code></em>.
  </p>
  <p class="para">
   You can find a list of all features in the <a href="http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/introduction.html#ID-Conformance" class="link external">&raquo;&nbsp;Conformance</a> section of the DOM
   specification.
  </p>
 </div>

 <div class="refsect1 parameters" id="refsect1-domimplementation.hasfeature-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">feature</code></em></dt>

     <dd>

      <p class="para">
       The feature to test.
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">version</code></em></dt>

     <dd>

      <p class="para">
       The version number of the <em><code class="parameter">feature</code></em> to test. In 
       level 2, this can be either <em>2.0</em> or
       <em>1.0</em>.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-domimplementation.hasfeature-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功时返回 <strong><code>TRUE</code></strong>， 或者在失败时返回 <strong><code>FALSE</code></strong>。
  </p>
 </div>

 <div class="refsect1 errors" id="refsect1-domimplementation.hasfeature-errors">
  <h3 class="title">错误／异常</h3>
  <p class="para">此方法<em class="emphasis">可以</em>被静态调用,但会抛出一个 <strong><code>E_STRICT</code></strong> 错误。</p>
 </div>

 <div class="refsect1 examples" id="refsect1-domimplementation.hasfeature-examples">
  <h3 class="title">范例</h3>
  <div class="example" id="example-5306">
   <p><strong>Example #1 Testing your DOM Implementation</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$features&nbsp;</span><span style="color: #007700">=&nbsp;array(<br />&nbsp;&nbsp;</span><span style="color: #DD0000">'Core'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'Core&nbsp;module'</span><span style="color: #007700">,<br />&nbsp;&nbsp;</span><span style="color: #DD0000">'XML'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'XML&nbsp;module'</span><span style="color: #007700">,<br />&nbsp;&nbsp;</span><span style="color: #DD0000">'HTML'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'HTML&nbsp;module'</span><span style="color: #007700">,<br />&nbsp;&nbsp;</span><span style="color: #DD0000">'Views'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'Views&nbsp;module'</span><span style="color: #007700">,<br />&nbsp;&nbsp;</span><span style="color: #DD0000">'Stylesheets'&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'Style&nbsp;Sheets&nbsp;module'</span><span style="color: #007700">,<br />&nbsp;&nbsp;</span><span style="color: #DD0000">'CSS'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'CSS&nbsp;module'</span><span style="color: #007700">,<br />&nbsp;&nbsp;</span><span style="color: #DD0000">'CSS2'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'CSS2&nbsp;module'</span><span style="color: #007700">,<br />&nbsp;&nbsp;</span><span style="color: #DD0000">'Events'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'Events&nbsp;module'</span><span style="color: #007700">,<br />&nbsp;&nbsp;</span><span style="color: #DD0000">'UIEvents'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'User&nbsp;interface&nbsp;Events&nbsp;module'</span><span style="color: #007700">,<br />&nbsp;&nbsp;</span><span style="color: #DD0000">'MouseEvents'&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'Mouse&nbsp;Events&nbsp;module'</span><span style="color: #007700">,<br />&nbsp;&nbsp;</span><span style="color: #DD0000">'MutationEvents'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'Mutation&nbsp;Events&nbsp;module'</span><span style="color: #007700">,<br />&nbsp;&nbsp;</span><span style="color: #DD0000">'HTMLEvents'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'HTML&nbsp;Events&nbsp;module'</span><span style="color: #007700">,<br />&nbsp;&nbsp;</span><span style="color: #DD0000">'Range'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'Range&nbsp;module'</span><span style="color: #007700">,<br />&nbsp;&nbsp;</span><span style="color: #DD0000">'Traversal'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'Traversal&nbsp;module'<br /></span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />foreach&nbsp;(</span><span style="color: #0000BB">$features&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$key&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">$name</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;if&nbsp;(</span><span style="color: #0000BB">DOMImplementation</span><span style="color: #007700">::</span><span style="color: #0000BB">hasFeature</span><span style="color: #007700">(</span><span style="color: #0000BB">$key</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'2.0'</span><span style="color: #007700">))&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"Has&nbsp;feature&nbsp;</span><span style="color: #0000BB">$name</span><span style="color: #DD0000">\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;}&nbsp;else&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"Missing&nbsp;feature&nbsp;</span><span style="color: #0000BB">$name</span><span style="color: #DD0000">\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;}<br />}<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

  </div>
 </div>

 <div class="refsect1 seealso" id="refsect1-domimplementation.hasfeature-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="methodname"><a href="domnode.issupported.html" class="methodname" rel="rdfs-seeAlso">DOMNode::isSupported()</a> - Checks if feature is supported for specified version</span></li>
   </ul>
  </p>
 </div>

</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="domimplementation.createdocumenttype.html">DOMImplementation::createDocumentType</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="class.domnamednodemap.html">DOMNamedNodeMap</a></div>
 <div class="up"><a href="class.domimplementation.html">DOMImplementation</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
